package cn.risebd.wepay.serializer;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

import cn.risebd.common.util.Strings;
import cn.risebd.wepay.model.enums.RefundChannel;

/**
 * 退款渠道反序列化器 @author 喝咖啡的蚂蚁  Date: 27/11/15
 * 
 * @since 1.0.0
 */
public class RefundChannelDeserializer extends JsonDeserializer<RefundChannel> {

	@Override
	public RefundChannel deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
		String val = jp.getValueAsString();
		if (Strings.isNullOrEmpty(val)) {
			return null;
		}
		return RefundChannel.from(val);
	}
}
